package org.madgecko.basic.util;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class PropertiesUtil {
	
	private static PropertiesUtil util = null;
	private static Map<String, Properties> props = null;
	
	private PropertiesUtil(){
	}
	public static PropertiesUtil getInstance(){
		if(null==util){
			util = new PropertiesUtil();
			props = new HashMap<String, Properties>();
		}
		return util;
	}
	public static Properties load(String name){
		try {
			if(null==props.get(name)){
				Properties prop = new Properties();
				prop.load(PropertiesUtil.class.getResourceAsStream("/" + name + ".properties"));
				props.put(name, prop);
			}
			return props.get(name);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
}
